package com.pm.main.controller;

import com.pm.main.controller.rsp.CategoryRsp;
import com.pm.main.infrastructure.category.CategoryPORepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import web.model.util.ModelUtils;

import javax.annotation.Resource;

/**
 * Created by cjwfuture on 2021/6/2
 */
@RestController
@RequestMapping("category")
@Api(tags = "商品分类")
public class CategoryController {

    @Resource
    public CategoryPORepository categoryPORepository;

    @ApiOperation("全部分类")
    @GetMapping
    public Flux<CategoryRsp> category() {
        return categoryPORepository.findAll().map(a -> ModelUtils.copy(a, CategoryRsp.class));
    }
}
